package com.woniu;

/**
 * @Author: 陈涵
 * @Do: 解释耦合
 * @DateTime: 22/08/17/0017 15:01
 **/

//耦合类
class Coupling implements CoupLingInterface{

}
class Coup implements  CoupLingInterface{

}
interface CoupLingInterface{

}


public class NoSpring {

  /*   // 耦合：没有定义接口CoupLingInterface的时候，NoSpring这个类，必须传入一个Coupling，才可以构造出NoSpring对象
    public  NoSpring(Coupling coupling){
        System.out.println(coupling);
    }*/

    //解耦
    public NoSpring(CoupLingInterface coupling) {
        System.out.println(coupling);
    }

    public static void main(String[] args) {
        NoSpring noSpring = new NoSpring(new Coupling());
        //明天改需求, 要修改这个对应的类，则强耦合会编译报错。可选方案通过接口解耦！
        Coup coup = new Coup();
        NoSpring noSpring1 = new NoSpring(coup);

    }
}
